package cn.xzhang.boot.mapper;

import cn.xzhang.boot.common.pojo.PageResult;
import cn.xzhang.boot.core.mapper.BaseMapperPlus;
import cn.xzhang.boot.model.dto.wallpaperCategories.WallpaperCategoriesPageReqDTO;
import cn.xzhang.boot.model.entity.WallpaperCategories;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import java.util.Objects;

/**
 * @author XiaoZhangCode
 * @description 针对表【wallpaperCategories(壁纸分类表)】的数据库操作Mapper
 * @author <a href="https://github.com/XiaoZhangCode">XiaoZhangCode</a>
 */
public interface WallpaperCategoriesMapper extends BaseMapperPlus<WallpaperCategories> {

    default PageResult<WallpaperCategories> selectPage(WallpaperCategoriesPageReqDTO wallpaperCategoriesPageReqDTO) {
        return selectPage(wallpaperCategoriesPageReqDTO, new LambdaQueryWrapper<WallpaperCategories>()
                .eq(Objects.nonNull(wallpaperCategoriesPageReqDTO.getSelected()), WallpaperCategories::getSelected, wallpaperCategoriesPageReqDTO.getSelected())
                .eq(Objects.nonNull(wallpaperCategoriesPageReqDTO.getEnabled()), WallpaperCategories::getEnabled, wallpaperCategoriesPageReqDTO.getEnabled())
                .like(Objects.nonNull(wallpaperCategoriesPageReqDTO.getId()), WallpaperCategories::getId, wallpaperCategoriesPageReqDTO.getId())
                .like(Objects.nonNull(wallpaperCategoriesPageReqDTO.getName()), WallpaperCategories::getName, wallpaperCategoriesPageReqDTO.getName())
                .orderByAsc(WallpaperCategories::getSort)
                .orderByDesc(WallpaperCategories::getCreateTime)

        );
    }

}




